package com.wtwd.campus.receiver;

import com.wtwd.campus.entity.MqPowerOnMessage;
import com.wtwd.campus.service.InjectFeignService;

public class UploadPowerOnDataReceiver implements Receiver {


    @Override
    public String parseMessage(String data) {
        // *WT,800115470000876,POWERON,170122,m1,595,MFD03_CTA_001,V,ALOE01002708,ALOE01002708,13912345678,FFFFDFFF#
        String[] split = data.split(",");
        String imei = split[1];
        String messageType = split[2];
        String commandNumber = split[3];
        String mode = split[4].substring(1);//当前工作模式
        String interval = split[5];//当前上报间隔
        String deviceStatus = split[11];
        String firmware = split[6];
        String m1Card = split[9];
        String uId = split[8];
        String phone = split[10];
        MqPowerOnMessage mqPowerOnMessage = new MqPowerOnMessage();
        mqPowerOnMessage.setAnswerVersion(uId);
        mqPowerOnMessage.setM1Card(m1Card);
        mqPowerOnMessage.setCommandNumber(commandNumber);
        mqPowerOnMessage.setFirmware(firmware);
        mqPowerOnMessage.setImei(imei);
        mqPowerOnMessage.setuId(uId);
        mqPowerOnMessage.setPhone(phone);
        mqPowerOnMessage.setStatus(deviceStatus);
        mqPowerOnMessage.setMode(Integer.parseInt(mode));
        mqPowerOnMessage.setInterval(Integer.parseInt(interval));
        InjectFeignService.getIrmFeignClientService().upPowerOn(mqPowerOnMessage);
        return imei;
    }
}
